import requests

url = 'https://baidu.com'
cookies = {'name': 'value'}

# 请求中添加cookie值
response = requests.get(url, cookies=cookies)

# 获取全部cookie
print(response.cookies)

# 获取每个cookie的name和value
for cookie in response.cookies:
    print(cookie.name, cookie.value)

# 删除指定cookie
response.cookies.pop('BD_HOME')
# 删除所有cookie
response.cookies.clear()

# 添加cookie到会话
session = requests.Session()

cookie = {"suyu", "miao"}

session.cookies.update(cookie)

response = session.get(url)
# 清除所有cookie
session.cookies.clear()
